//
//  NSStringAdditions.h
//  Tint
//
//  Created by Kevin Wu on 2/22/12.
//  Copyright (c) 2012 Telligenty. All rights reserved.
//

#import <Foundation/Foundation.h>


@interface NSString (Tint)

/*
 * Creating
 */
+ (NSString *)newUUIDString;

- (NSData *)newASCIIEncodingData;
- (NSData *)newUTF8EncodingData;
- (NSData *)newDataUsingEncoding:(NSStringEncoding)encoding;

/*
 * Hash
 */
- (NSString *)newMD5HashString;
- (NSString *)newSHA1HashString;

/*
 * Validity
 */
- (BOOL)isEmailAddress;
- (BOOL)isInCharacterSet:(NSCharacterSet *)characterSet;
// space (U+0020), tab (U+0009), newline and nextline characters (U+000A–U+000D, U+0085). 
- (BOOL)isWhitespaceAndNewlines;
// Zero and positive number (e.g., "000", "0124", "342").
- (BOOL)isNonNegativeNumber;

/*
 * URL
 */
- (NSString *)newURLEncodedString;
- (NSString *)newURLDecodedString;

- (NSDictionary *)newQueryDictionary;
- (NSString *)newStringByAddingQueryDictionary:(NSDictionary *)dictionary;
- (NSString *)newStringByAppendingParameter:(NSString *)paramter forKey:(NSString *)key;

/*
 * Triming and replacing
 */
- (NSString *)newStringByTrimmingWhitespace;
- (NSString *)newStringByTrimmingWhitespaceAndNewline;

- (NSString *)newStringByReplacingString:(NSString *)searchString withString:(NSString *)newString; // Case sensitive
- (NSString *)newStringByReplacingString:(NSString *)searchString withString:(NSString *)newString ignoringCase:(BOOL)ignore;

/*
 * Finding and comparing
 */
- (BOOL)containsString:(NSString *)string; // Case sensitive
- (BOOL)containsString:(NSString *)string ignoringCase:(BOOL)ignore;

- (BOOL)equalsToString:(NSString *)string; // Case sensitive
- (BOOL)equalsToString:(NSString *)string ignoringCase:(BOOL)ignore;

@end




@interface NSMutableString (Tint)

/*
 * URL
 */
- (void)addQueryDictionary:(NSDictionary *)dictionary;
- (void)appendParameter:(NSString *)paramter forKey:(NSString *)key;

/*
 * Triming and replacing
 */
- (void)trimCharactersInSet:(NSCharacterSet *)characterSet;
// Remove from both ends of the receiver characters contained in whitespace character set.
- (void)trimWhitespace;
// Remove from both ends of the receiver characters contained in whitespace and newline character set.
- (void)trimWhitespaceAndNewline;

- (void)replaceString:(NSString *)searchString withString:(NSString *)newString; // Case sensitive
- (void)replaceString:(NSString *)searchString withString:(NSString *)newString ignoringCase:(BOOL)ignore;

@end
